home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 1.9 KB | 76 lines | [TEXT/MPS ] |
- (*
- CTBCharsAvailable() -- Return the number of characters immediately available for reading.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBCharsAvailable.p
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=2751 -sn Main=CTBCharsAvailable ∂
- CTBCharsAvailable.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBCharsAvailable } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBCharsAvailable(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBCharsAvailable(paramPtr);
- end;
-
- procedure CTBCharsAvailable(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var l: longInt;
- sizes: CMBufferSizes;
- status: CMStatFlags;
- s: Str255;
- theBuf: InputBufferHandle;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBCharsAvailable);
- end;
-
- begin
- { Check the parameter count. }
- if paramPtr^.paramCount <> 0 then Fail('Invalid parameter count');
-
- { Make sure the Comm Toolbox is willing. }
- CTBReady;
- { And the connection tool's here. }
- EnsurePresent(connectionTool);
- { And it's open. }
- EnsureOpen;
-
- { Get the input buffer. }
- theBuf := InputBufferHandle(CMGetUserData(Globals^^.connHand));
- { Find out how many bytes are available. }
- if CMStatus(Globals^^.connHand,sizes,status) = noErr then
- l := sizes[cmDataIn] + theBuf^^.amountLeft
- else l := theBuf^^.amountLeft;
- { Convert it to a string and return it. }
- LongToStr(paramPtr,l,s);
- paramPtr^.returnValue := PasToZero(paramPtr,s);
- end;
-
- end.
-